package guavaTest;

import com.google.common.base.Stopwatch;

import java.util.concurrent.TimeUnit;

/**
 * @Author: huangkunming
 * @Date: 2023/7/27 12:01
 * @Description:
 */
public class StopWatch {

    public static void main(String[] args) throws InterruptedException {
        Stopwatch stopwatch = Stopwatch.createStarted();
        Thread.sleep(1000);
        System.out.println("开始①====>" + stopwatch.elapsed(TimeUnit.MILLISECONDS));

        Thread.sleep(1500);
        System.out.println("开始①====>" + stopwatch.elapsed(TimeUnit.MILLISECONDS));

        stopwatch.stop();
        Thread.sleep(1000);
        System.out.println("停止①====>" + stopwatch.elapsed(TimeUnit.MILLISECONDS));

        stopwatch.reset();
        Thread.sleep(1000);
        System.out.println("重置①====>" + stopwatch.elapsed(TimeUnit.MILLISECONDS));

        stopwatch.start();
        Thread.sleep(1000);
        System.out.println("开始③====>" + stopwatch.elapsed(TimeUnit.MILLISECONDS));

        System.out.println("是否执行中①====>" + stopwatch.isRunning());
        stopwatch.stop();
        System.out.println("是否执行中②====>" + stopwatch.isRunning());


    }

}
